import {NavTo} from '@/utlis/uni_api'
import {ref, reactive, defineEmits} from 'vue'
import {exitLogin as exitLoginmodule, useStore} from '@/Pinia/index'
import * as $http from '@/utlis/interface/Wode'

interface OperationList {
    icon: string
    title: string
    switch: boolean,
    mode: string,
    click?: () => void
    style: any
}

interface myInfo {
    avatar: string | null
    nickName: string | null
    realNameStatus: string | number
    satisfactionDegree: string | number
    status: string | number
    totalOrder: string | number
}

export default (Proxy: any, emit: any) => {
    const {exit} = exitLoginmodule()
    const Meswitch = ref<any>(null) // 我的状态按钮
    const realNameStatus = ref<any>()  //是否实名认证
    const nowstatus = useStore()
    nowstatus.infoData.userWorkStatus == 0 ? Meswitch.value = true : Meswitch.value = false
    setTimeout(() => {
        realNameStatus.value = nowstatus.infoData.userRealNameStatus
    }, 1000)
    //我的状态
    const setStatus = (Proxy: any,) => {
        $http.myStatus('', Proxy).then((res: any) => {
            if (res.code == 0) {
                nowstatus.infoData.userWorkStatus = res.data
                emit('swtichChange')
            }
        })
        setTimeout(() => {

        }, 500)
    }

    const openMePoP = () => {
    }
    // 我的账户
    const wallet = () => {
        NavTo('/pages/Wode/account')
    }
    // 设置
    const setting = () => {
        NavTo('/pages/Wode/setting')
    }
    // 订单统计
    const orderStatistics = () => {
        NavTo('/pages/Wode/orderStatistics')
    }
    const OperationList = ref<Array<OperationList>>([
        {
            icon: '../../static/images/pulice/status.png',
            title: '我的状态',
            switch: true,
            mode: 'aspectFit',
            style: ''

        },
        // {
        //   icon: '../../static/images/pulice/wallet.png',
        //   title: '我的账户',
        //   switch: false,
        //   click: wallet,
        //   mode: 'aspectFit',
        //   style: ''
        // },
        {
            icon: '../../static/images/pulice/setting.png',
            title: '设置',
            switch: false,
            click: setting,
            mode: 'aspectFit',
            style: ''
        },
        // {
        //     icon: '../../static/images/pulice/setting.png',
        //     title: '订单统计',
        //     switch: false,
        //     click: orderStatistics,
        //     mode: 'aspectFit',
        //     style: ''
        // },
    ])
    // 退出登录模态框
    const exitShow = ref<boolean>(false)
    const exitLogin = () => {
        exitShow.value = false
        Proxy.$API(Proxy).Toast('退出成功', 'success')
        exit()
    }

    const toRealName = () => {
        if(realNameStatus.value == 0){
            emit('setSkipModel2')
            emit('MeShowclose')

        }
    }
    return {
        openMePoP,
        Meswitch,
        OperationList,
        exitLogin,
        exitShow,
        realNameStatus,
        setStatus,
        toRealName

    }
}
